﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace SimpleMvvmDemo.Commands
{
    public class DelegateCommand : ICommand
    {
        public bool CanExecute(object? parameter)
        {
            if (this.CanExcuteFunc == null)
            {
                return true;
            }
            return this.CanExcuteFunc.Invoke(parameter);
        }

        public void Execute(object? parameter)
        {
            if (this.ExcuteAction == null)
            {
                return;
            }
            this.ExcuteAction.Invoke(parameter);
        }

        public event EventHandler? CanExecuteChanged;

        public Action<object> ExcuteAction { get; set; }
        public Func<object, bool> CanExcuteFunc { get; set; }
    }
}
